home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <memory.h>
- #include <dos.h>
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- unsigned char line[81],bytes[80],far *byte,tmp, *strupr();
- int addr,val,num,fh,type,i,seg320,io320,go;
- FILE *fp;
- if (argc>4) {
- if ((fp = fopen(argv[1],"r")) == NULL) {
- strcpy(line,argv[1]);
- strcat(line,".hex");
- puts(line);
- if ((fp = fopen(line,"r")) == NULL) {
- fprintf(stderr,"%s couldn't find the file %s\n",argv[0],argv[1]);
- exit(1);
- }
- }
- seg320=atoh(strupr(argv[2]),0,4);
- io320=atoh(argv[3],0,3);
- go=atoi(argv[4]);
- }
- else {
- fprintf(stderr,"usage: intel filename(.hex) segment ioport go(0 or 1)\n");
- exit(1);
- }
- inp(io320+7);
- fh=fileno(fp);
- byte = bytes;
- while (1) {
- fgets(line,80,fp);
- num=atoh(line,1,2);
- addr=atoh(line,3,4);
- type=atoh(line,7,2);
- if (type==0) {
- for(i=0;i<num;i+=2) {
- bytes[i]=atoh(line,2*i+9,2);
- bytes[i+1]=atoh(line,2*i+11,2);
- tmp=bytes[i];
- bytes[i]=bytes[i+1];
- bytes[i+1]=tmp;
- }
- movedata(FP_SEG(byte),FP_OFF(byte),seg320,addr,(unsigned)num);
- }
- else break;
- }
- printf("\n segment=%x ioaddr=%x go=%x\n",(unsigned)seg320,io320,go);
- if (go==1) inp(io320+6);
- }
-
- int atoh(str,pos,len)
- unsigned char *str;
- int pos,len;
- {
- int num,i;
- num = 0;
- for(i=0;i<len;i++) {
- if (*(str+i+pos)<58) num += ((*(str+i+pos)-48)<<(4*(len-i-1)));
- else num += ((*(str+i+pos)-55)<<(4*(len-i-1)));
- }
- return(num);
- }
-